#!/bin/bash
#Written by: Igor Rafael [igor@dcc.ufmg.br]

#########################################################################
#                                                                       #
#   - To execute:                                                       #
#       ./run <shell>                                                   #
#                                                                       #
#   - To disable a test file, put a # before its name in the LIST file  #
#                                                                       #
#########################################################################

SUITE_PATH=.
SHELL=$1
flags=cp

OPT_PARAM="-n --ion --ion-cp=on --ion-gvn=off"

if [ -d $SUITE_PATH ];then
if [ -e $SHELL ];then    
    
    #Calculates the percentage of active tests
    TOTAL=0
    ENABLED=0

    for TEST_FILE in `cat $SUITE_PATH/LIST`; do  
        TOTAL=`expr $TOTAL + 1` ;
    done

    for TEST_FILE in `cat $SUITE_PATH/LIST | grep -v "^#"`; do  
        echo ""
        echo ""
        echo "Running $TEST_FILE" ;
        ENABLED=`expr $ENABLED + 1` ;
        IONFLAGS=${flags} $SHELL -b $OPT_PARAM $SUITE_PATH/$TEST_FILE
    done

    echo ""
    echo "Active tests: $ENABLED/$TOTAL"
    echo ""

else
    echo "JS shell path not found"
    echo ""
fi
else
    echo "Test suite path not found"
    echo ""
fi 
